// 全局store,存放全局使用共享的数据
export default { // 注意：全局模块中不需要开启命名空间
    getters: {
        getMusicList(state, getters) {
            console.log("1 =", state.kugouNet.playList)
            return [...state.local.musicList, ...state.kugouNet.playList];
        }
        /*getTodoById: (state) => (id) => {
            return state.todos.find(too => too.id === id)
        }*/
    },
    actions: {},
    mutations: {
        EMPTY(state) {
            state.playList.length = 0;
        },
        ADD_MUSIC(state, music) {
            state.playList.push(music);
            console.log("state.playList1 =", state.playList)
        },
        ADD_MUSIC_EMPTY(state, music) {
            state.playList.length = 0;
            state.playList.push(music);
            console.log("state.playList2 =", state.playList)
        },
        ADD_MUSIC_LIST(state, playList) {
            state.playList.push(...playList);
            console.log("state.playList3 =", state.playList)
        },
        ADD_MUSIC_LIST_EMPTY(state, playList) {
            console.log("playList4 =", playList)
            state.playList.length = 0;
            state.playList.push(...playList);
            console.log("state.playList4 =", state.playList)
        },
        // 跟具id修改state.playList状态
        SET_MUSIC_BY_ID(state, music) {
            // 变更状态
            if (music.id) {
                try {
                    state.playList.forEach((m) => {
                        if (music.id === m.id) {
                            m = music;
                            throw new Error('true');
                        }
                    })
                } catch (e) {
                    if (e.message !== "true") throw e
                }
            }
        },
        // 修改播放音乐的播放状态
        SET_MUSIC_PLAYING(state, id) {
            state.playList.forEach((m) => {
                m.isPlaying = m.id === id;
            })
        },
        ADD_MARK(state, music) {

            console.log("collectionList =", state.collection.playList)
        }
    },
    state: {
        playingMusicId: -1,
        playingMusic: {},
        playList: [
            {
                "id": "4A95376F98B4CA98C6DC58D1B7773774",
                "title": "再回首",
                "artist": "姜育恒",
                "album": "",
                "size": "3.9M",
                "type": "NET",
                "isPlaying": true,
                "isSelected": true,
                "isLoading": false,
                "isCollection": false
            },
            {
                "id": "44B748C5F21B132BB8890FA3F2F6AD21",
                "title": "其实不想走其实不想走其实不想走其实不想走其实不想走其实不想走其实不想走其实不想走其实不想走",
                "artist": "周华健周华健周华健周华健周华健周华健",
                "album": "",
                "size": "4.72M",
                "type": "NET",
                "isPlaying": false,
                "isSelected": true,
                "isLoading": false,
                "isCollection": false
            },
            {
                "id": "3E9DA1CED72ABF170D3DBF7722F147A3",
                "title": "对你爱不完",
                "artist": "郭富城",
                "album": "",
                "size": "4.24M",
                "type": "NET",
                "isPlaying": false,
                "isSelected": true,
                "isLoading": false,
                "isCollection": false,
                "isPlay": false
            },
            {
                "id": "949493B957E893B2CA701AB7F10C3882",
                "title": "牵挂你的人是我",
                "artist": "高林生",
                "album": "",
                "size": "3.78M",
                "type": "NET",
                "isPlaying": false,
                "isSelected": true,
                "isLoading": false,
                "isCollection": false
            },
            {
                "id": "AB8D686C0B5C099BCA9911519FC51E0E",
                "title": "心雨",
                "artist": "杨钰莹、毛宁",
                "album": "",
                "size": "4.18M",
                "type": "NET",
                "isPlaying": false,
                "isSelected": true,
                "isLoading": false,
                "isCollection": false
            }
        ],
        //musicList: [],
    },
}
